require "top_notify/version"

module TopNotify

	TYPE = {
		200 => {:method => :connected,              :msg => "connect to taobao server"},
		201 => {:method => :heartbreak,             :msg => "receive heartbreak"},
		202 => {:method => :receive_msg,            :msg => "receive msg"},
		203 => {:method => :discard_msg,            :msg => "receive discard msg"},
		101 => {:method => :connect_reach_max_time, :msg => "connection reach max time"},
		102 => {:method => :server_upgrate,         :msg => "taobao server under upgrade"},
		103 => {:method => :server_rehash,          :msg => "taobao server close the connection"},
		104 => {:method => :client_kickoff,         :msg => "client kickoff"},
		105 => {:method => :server_kickoff,         :msg => "server kickoff"},
    0   => {:method => :unknown_msg,            :msg => "unknown msg"}
	}

  class << self

    def setup
      yield self
    end

    def app_key=(app_key)
      @app_key = app_key
    end

    def app_secret=(app_secret)
      @app_secret = app_secret
    end

    def logger=(device)
      @logger = device
    end

    def logger
      @logger
    end

    def app_key
      @app_key
    end

    def app_secret
      @app_secret
    end

    def service_url
      @service_url ||= 'http://stream.api.taobao.com/stream'
    end
  end

end

require 'top_notify/server'
require 'top_notify/exception'
require 'top_notify/connection'
